SRC = $(wildcard src/mahjong/*.java)
OBJ = $(subst .java,.class,$(subst src,bin,$(SRC)))
OBJDIR = bin/mahjong
SRCDIR = src/mahjong

code: $(OBJ)

all: code doc

run: code
	java -cp ./bin/ mahjong.Main

unit: unit1 unit2 unit3

unit1: $(OBJ)
	java -cp ./src/JUnit.jar:./bin/ org.junit.runner.JUnitCore mahjong.Milestone1Test

unit2: $(OBJ)
	java -cp ./src/JUnit.jar:./bin/ org.junit.runner.JUnitCore mahjong.Milestone2Test

unit3: $(OBJ)
	java -cp ./src/JUnit.jar:./bin/ org.junit.runner.JUnitCore mahjong.Milestone3Test

doc: $(SRC)
	javadoc -classpath ./src/JUnit.jar -d ./doc/ -sourcepath ./src mahjong

bin/mahjong/Milestone1Test.class : src/mahjong/Milestone1Test.java
	javac -Xlint:unchecked -d ./bin/ -cp ./src/JUnit.jar -sourcepath ./src/ $<

bin/mahjong/Milestone2Test.class : src/mahjong/Milestone2Test.java
	javac -Xlint:unchecked -d ./bin/ -cp ./src/JUnit.jar -sourcepath ./src/ $<

bin/mahjong/Milestone3Test.class : src/mahjong/Milestone3Test.java
	javac -Xlint:unchecked -d ./bin/ -cp ./src/JUnit.jar -sourcepath ./src/ $<

bin/mahjong/%.class: src/mahjong/%.java
	javac -Xlint:unchecked -d ./bin/ -cp ./src/ $< 

clean:
	rm -f ./bin/mahjong/*.class
